package com.rongzhe.house.article.service;

import com.rongzhe.house.article.bo.ArticleBo;
import com.rongzhe.house.article.dao.ArticleMapper;
import com.rongzhe.house.article.dao.ArticleTagMapper;
import com.rongzhe.house.common.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author Chengjia
 * @date 2018/3/3 11:36
 */
@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleMapper articleMapper;
    @Autowired
    private ArticleTagMapper articleTagMapper;

    @Override
    public ArticleBo selectByID(Integer id) {
        ArticleBo articleBo = articleMapper.selectById(id);
        articleBo.setCreateTime(DateUtil.getFormatDateTime(articleBo.getInsertTime(),"yyyy-MM-dd"));
        Set<String> datas=null;
        if(null!=articleBo){
            datas = articleTagMapper.selectArticleTagIds(id);
            articleBo.setArticleTags(datas);
        }
        return articleBo;
    }
}
